﻿Namespace GameState
  Public Class SecondMoveGameState
    Inherits AbstractGameState

    ''' <summary>
    ''' show the second card and wait
    ''' </summary>
    Friend Overrides Sub DoTurn(ByVal card As Card)
      'find player
      Dim player As Player = MovingPlayer()
      If player Is Nothing Then
        Throw New InvalidOperationException("No active player found in second move")
      End If

      'turn and keep the card
      SecondCard = card
      SecondCard.Turn()

      'check to see if the cards are the same
      If FirstCard.TwinCard Is SecondCard Then
        'they are,  player will gain two cards
        player.SetTurnState(player.TurnStateE.WinsTurn)
      Else
        'wrong, player looses turn
        player.SetTurnState(player.TurnStateE.LoosesTurn)
      End If

      'advice a wait-and-evaluate turn
      adviceGameState(Of WaitAndProcessSecondTurnGameState)()
    End Sub
  End Class
End Namespace